$(function(){
	if(typeof(_param_id)!='undefined' && _param_id.length > 0){
		_set_default_lable_text('sys/LoanExt/checkSubmit?pks=' + _param_id,true);	
		$.ajax({
	       	url:'sys/LoanExt/accessoryGroup',
	    	data:{'queryProxy[loanId]':_param_id,'queryProxy[enable]':0,'queryProxy[ownerType]':'SQ'},
	    	type:'post',
	    	dataType:'json',
	    	async:false,
	    	success:function(result){
	    	        if(typeof(result)!='undefined' && result.state == 200){
	    	          var accessoryClassApplyCodes = top.SYS_BASE_DATA['Accessory_Class_Apply_Code'],data=result.rows,li=getgetAccessoryLis2(accessoryClassApplyCodes,data);
	    	          if(_is_not_empty(li)){
	    	        	 $('#accessoryInfo').after($(li));
	    	          }
	    	        }
	    		},
	    		complete:function(){
	    		}
	        });
	}
});


var getgetAccessoryLis2 = function(accessoryClassApplyCodes,data){
    var li='';
	$.each(accessoryClassApplyCodes,function(key,value){
		  $.each(data,function(index,obj){
			  var label = obj['LABEL'],num=obj['NUM'];
			  if(_is_not_empty(label) && label  == key){
				  li = li+'<li><label>&nbsp;</label><label2><j>'+value+':</j><b><span>'+num+'</span></b>个</label2></li>';
			   }
		     });
   });
	return li;
}

var getgetAccessoryLis1 = function(accessoryClassApplyCodes,data){
	var li = '';
	$.each(accessoryClassApplyCodes,function(key,value){
	       var num = getAccessoryNum(key,data); ;
	       li = li+'<li><label>&nbsp;</label><label2><j>'+value+':</j><b><span>'+num+'</span></b>个</label2></li>';
   });
	return li;
}
var getAccessoryNum = function(key,data){
	 if(_is_empty(data)){
		 return 0;
	 }
	 for(var key in data){
		 var obj = data[key],label = obj['LABEL'];
		 if(_is_not_empty(label) && label  == key){
			   return obj['NUM'];
		   }
	 }
};
var submitApply = function(){
	$.ajax({
       	url:'sys/LoanExt/submitApply',
    	data:{pks:_param_id},
    	type:'post',
    	dataType:'json',
    	async:false,
    	success:function(result){
    	        if(typeof(result)!='undefined' && result.state == 200){
   	        	
    	        	$.dialog({
    					icon: 'success.gif',
    					title: '提示',
    				    content: result.message,
    				    ok: function(){
    				    	top._do_goto_right('jsp/loan/applyLoanList_.jsp');
    				    }
    				});
    	            return false;
    	        }
    	        $.dialog.alert(result.message);
    		},
    		complete:function(){
    		}
        });
};



